package top.wenzz.manage.system.manage.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.wenzz.manage.system.manage.dao.SysRoleDao;
import top.wenzz.manage.system.manage.entity.SysRole;
import top.wenzz.commons.service.BasicService;

/**
 * 资源service
 * Created by 钟廷员 on 2016/12/12.
 */
@Service
public class SysRoleService extends BasicService<SysRole, SysRoleDao> {

    @Transactional
    public String updatePermission(SysRole entity) throws Exception {
        SysRole e = getOne(entity.getId());
        if(e == null)
            return "不存在该数据";
        if(e.getVersion() != entity.getVersion())
            return "数据已被修改，请刷新后操作";
        e.setPermissions(entity.getPermissions());
        updateEntity(e);
        return null;
    }

}
